<?php
include '../AopClient.php';
include '../SignData.php';
include('../AlipayMobilePublicMultiMediaClient.php');
include('../request/AlipayMarketingCardQueryRequest.php');
include('../request/AlipayMarketingCardFormtemplateSetRequest.php');
include('../request/AlipayMarketingCardTemplateQueryRequest.php');
include('../request/AlipayMarketingCardTemplateCreateRequest.php');
include('../request/AlipayMarketingCardActivateurlApplyRequest.php');
include('../request/AlipayMarketingCardOpenRequest.php');
$aop = new AopClient();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = '2018011901971979';
$aop->rsaPrivateKey = 'MIIEpAIBAAKCAQEA0Hx+9wgN4ParmGATI2ykd4HnwqV2yhUKfPXCLWMXCxyT83akGBPt/svUBeYCd5ZhVMMebYQ6ZfJVtfCCF6aQAQQvZujgcCdWm4nO6W1w7ryIhuwvT1ocsBKBGl3g+9YfvHWfPx2otIpvL5xPBYz3+0bk0Ge5EuVT4xjNsfIfNVMhOCddtX0VOfNFE7gzu6uVsEatFXLcwq2qCTVrx4SWjLCpYVmTdtoFAgJqrSvuXHDccAj7lA44vy1xJRpfzhddE+uQ2G+wcoK6Z/CW6RDpJ1zLhfcSRfvxO+gWLk72UI7W6U3LAa5ULc3moUqFbOfjE73fjQIynCIoAT1AdRq7WwIDAQABAoIBAQCBiQid1dxBrSFakD7z4JmjQwxLbOEMl9wnXc6iwpFbrwrh1xIHf8J8cAoxDAL2aHHa50xtgR2Dn/jPDTrXFP8eEoqdJw3jwR1XkF0FvaDQREWThwWyCOwQHb8nMbMK5bRcNLyXy4a5fdWtQDH84eRltFuQfRGJgwEG9a8/446uYvP5ZuW5DDyGWKJ6XbQbaYfsZ7ID5ek4/I9xZYUeMRe8xyeGB2Es4Gq0Cz0q2uGicUOB2d28nPNnK9gzSrJIo3EZu9nJg+T83YSMeO5f0T3YW1Id2nvL4Ksbp6Gx23jLbGCIKcDKzJLgt/yJBEokYHaTzU1VN98yBbTor27XSik5AoGBAOvQ4LCNpOwJLVpX+JC/7yFz24XfnYy8gq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Fh09w/mvMpRFzYb/FlfUl72ewOr7FCRn3mBu5PYDNkrTQiNiECOXj1bO6/O6rFZ8lqvOV7Tb0hk8iobT19dMhlUCR4jE1jWGTTHVHZh1OrlV1zHjkHcRdLihCyMM3WQWz5pOvDuBhtl9JVA/MaeeFEgHTxde3QIDAQAB';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='utf-8';
$aop->format='json';

$request = new AlipayMarketingCardOpenRequest ();
$post_data=[
    'out_serial_no'=>'E201611250222479XXeX1',
    'card_template_id'=>'20180122000000000774265000300735',
    'card_user_info'=>[
'user_uni_id'=>'2088012954780622',
'user_uni_id_type'=>'UID',
    ],
    'card_ext_info'=>[
        'biz_card_no' => 'hha',#支付宝业务卡号 说明： 1、开卡成功后返回该参数，需要保存留用； 2、开卡/更新/删卡/查询卡接口请求中不需要传该参数；
        'external_card_no'=>'11111', # 商户外部会员卡卡号 说明： 1、会员卡开卡接口，如果卡类型为外部会员卡，请求中则必须提供该参数； 2、更新、查询、删除等接口，请求中则不需要提供该参数值；
        'open_date' => date('Y-m-d H:i:s'),
        'valid_date' => date('2022-m-d H:i:s'),
        'level' =>'VIP1',
        'point' => '88',
        'balance' => '128.88'
    ],
];
$request->setBizContent(json_encode($post_data,JSON_UNESCAPED_UNICODE));

$result = $aop->execute ( $request,'composeB5751bd1598ce445eab6ebfcc84a79X62'  );

$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
var_dump($result);
if(!empty($resultCode)&&$resultCode == 10000){
echo "成功";
} else {
echo "失败";
}